const app = getApp();
Page({
  data: {
    cid: 0,
    consult: {},
    url: '',
    conId: 0,
    consultconti:{},
    consultList: [],
    specialtyList: [],
    chargetList:[],
    pageSize:0,
    questiontList:[],
    UserMarkList:[],
    courseList:[],
    isLoading:false
  },
  onClickLeft() {
    wx.navigateBack()
  },
  toDetail() {
    wx.navigateTo({
      url: '#',
    })
  },
  onLoad(options) {
    wx.showLoading({
      title:'正在加载中...',
      icon:'loading',
      mask:true
    });
    const id = options.id;
    const conId = id;
    console.log(1111,id);
    this.setData({
      cid: id,
      url: app.globalData.URL,
      isLoading:true
    });
    let that = this;
    wx.request({
      url: that.data.url + 'consult/' + that.data.cid,
      method: 'GET',
      success(resp) {
        that.setData({
          consult: resp.data.data,
        })
      },
    });
    wx.request({
      url: that.data.url + 'consultconti/selectByConId/' + conId,
      method:'GET',
      success(resp){
        console.log(resp.data);
        that.setData({
          consultconti:resp.data.data,
        })
      }
    })
    wx.request({
      url: that.data.url + 'consultspecialty/selectAll',
      method: 'GET',
      success(resp) {
        //console.log("resp",resp.data.data)

        that.setData({
          specialtyList: resp.data.data,
        })
        //console.log("1111",that.data.specialtyList);
      },
      complete(){
        wx.hideLoading();
        wx.stopPullDownRefresh();
        that.setData({
          isLoading:false
        })
      }
    })
        wx.request({
          url: that.data.url + 'consult/findAll',
          method: 'GET',
          success(resp) {
            that.setData({
              consultList: resp.data.data.list,
            })
            //console.log("222",that.data.consultList);
          },
          complete(){
            wx.hideLoading();
            wx.stopPullDownRefresh();
            that.setData({
              isLoading:false
            })
          }
        })
        wx.request({
          url: that.data.url + 'charge/selectAll',
          method:'GET',
          data:{
            pageSize:3
          },
          success(resp) {
            that.setData({
              chargetList: resp.data.data,
            })
          }
        })
        wx.request({
          url: that.data.url + 'question/findAll',
          method:'GET',
          data:{
            pageSize:3
          },
          success(resp) {
            that.setData({
              questiontList: resp.data.data.list,
            })
          }
        })
        wx.request({
          url: that.data.url + 'UserMarkController/selectUserMark',
          method:'GET',
          data:{
            pageNum:1,
            pageSize:3
          },
          success(resp) {
            console.log(resp.data)
            that.setData({
              UserMarkList: resp.data.data,
            })
            console.log(that.data.UserMarkList)
          }
        })
        wx.request({
          url: that.data.url + 'course/findAll',
          method:'GET',
          data:{
            pageSize:100
          },
          success(resp) {
            console.log(resp.data)
            that.setData({
              courseList: resp.data.data.list,
            })
            console.log(that.data.courseList)
          },
          complete(){
            wx.hideLoading();
            wx.stopPullDownRefresh();
            that.setData({
              isLoading:false
            })
          }
        })
  },
  onShow: function () {

  },
  showPopup() {
    this.setData({
      popupShow: true
    });
  },
  onPopupClose() {
    this.setData({
      popupShow: false
    });
  },
  toQuestionDetail:function(e) {
    const id = e.currentTarget.dataset.id;
    //console.log("1"+id);
    wx.navigateTo({
      url: '/pages/consult/consultDetail/QuestionDetail/QuestionDetail?id='+id,
    });
  },
})